SRC = ../src/ebook/ebook.cpp \
      ../src/ebook/ebookpage.cpp \
      ../src/ebook/backbookindex.cpp \
      ../src/ebook/dictionary.cpp \
      ../src/utils/fileutils.cpp \
      ../src/structures/trie.cpp \
      ../src/converter/utf16encode.cpp

OBJ = $(patsubst %.cpp,obj/%.o,$(SRC))

OUT = libebook.a

INCLUDES= -I../src

LIBS = -L/user/local/lib -lm

#Compiler flags
CCFLAGS = -fPIC -g -Wall
LDFLAGS = rcs

#compiler
CCC = g++
AR = ar

default: $(OUT)

$(OBJ): | obj

obj:
	@echo creating objects directory $@
	@mkdir -p $@
	@mkdir -p $(patsubst %/, $@/%, $(sort $(dir $(SRC))))

obj/%.o : %.cpp
	$(CCC) $(INCLUDES) $(CCFLAGS) -c $< -o $@

#archive the library
$(OUT):$(OBJ)
	$(AR) $(LDFLAGS) $(OUT) $(OBJ)

.PHONY: clean    
clean:
	rm -f $(OBJ)
	rm -f $(OUT)
	rm -rf obj
